/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "activity")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Activity.findAll", query = "SELECT a FROM Activity a"),
    @NamedQuery(name = "Activity.findById", query = "SELECT a FROM Activity a WHERE a.id = :id"),
    @NamedQuery(name = "Activity.findByName", query = "SELECT a FROM Activity a WHERE a.name = :name"),
    @NamedQuery(name = "Activity.findByEnergyProfile", query = "SELECT a FROM Activity a WHERE a.energyProfile = :energyProfile"),
    @NamedQuery(name = "Activity.findByExecutionTime", query = "SELECT a FROM Activity a WHERE a.executionTime = :executionTime"),
    @NamedQuery(name = "Activity.findByMinExecTime", query = "SELECT a FROM Activity a WHERE a.minExecTime = :minExecTime"),
    @NamedQuery(name = "Activity.findByMaxExecTime", query = "SELECT a FROM Activity a WHERE a.maxExecTime = :maxExecTime"),
    @NamedQuery(name = "Activity.findByCPUIdleTime", query = "SELECT a FROM Activity a WHERE a.cPUIdleTime = :cPUIdleTime"),
    @NamedQuery(name = "Activity.findByCPUNormalTime", query = "SELECT a FROM Activity a WHERE a.cPUNormalTime = :cPUNormalTime"),
    @NamedQuery(name = "Activity.findByCPUUsage", query = "SELECT a FROM Activity a WHERE a.cPUUsage = :cPUUsage"),
    @NamedQuery(name = "Activity.findByDiskReadTime", query = "SELECT a FROM Activity a WHERE a.diskReadTime = :diskReadTime"),
    @NamedQuery(name = "Activity.findByDiskWriteTime", query = "SELECT a FROM Activity a WHERE a.diskWriteTime = :diskWriteTime"),
    @NamedQuery(name = "Activity.findByDiskIdleTime", query = "SELECT a FROM Activity a WHERE a.diskIdleTime = :diskIdleTime"),
    @NamedQuery(name = "Activity.findByDiskSleepTime", query = "SELECT a FROM Activity a WHERE a.diskSleepTime = :diskSleepTime"),
    @NamedQuery(name = "Activity.findByDiskStbTime", query = "SELECT a FROM Activity a WHERE a.diskStbTime = :diskStbTime"),
    @NamedQuery(name = "Activity.findByDiskUsage", query = "SELECT a FROM Activity a WHERE a.diskUsage = :diskUsage")})
public class Activity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Column(name = "Name")
    private String name;
    @Column(name = "EnergyProfile")
    private String energyProfile;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "ExecutionTime")
    private BigDecimal executionTime;
    @Column(name = "MinExecTime")
    private BigDecimal minExecTime;
    @Column(name = "MaxExecTime")
    private BigDecimal maxExecTime;
    @Column(name = "CPUIdleTime")
    private BigDecimal cPUIdleTime;
    @Column(name = "CPUNormalTime")
    private BigDecimal cPUNormalTime;
    @Column(name = "CPUUsage")
    private BigDecimal cPUUsage;
    @Column(name = "DiskReadTime")
    private BigDecimal diskReadTime;
    @Column(name = "DiskWriteTime")
    private BigDecimal diskWriteTime;
    @Column(name = "DiskIdleTime")
    private BigDecimal diskIdleTime;
    @Column(name = "DiskSleepTime")
    private BigDecimal diskSleepTime;
    @Column(name = "DiskStbTime")
    private BigDecimal diskStbTime;
    @Column(name = "DiskUsage")
    private BigDecimal diskUsage;
    @JoinTable(name = "activity_services", joinColumns = {
        @JoinColumn(name = "Id_Activity", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "Id_Service", referencedColumnName = "ID")})
    @ManyToMany
    private Collection<Service> serviceCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activity")
    private Collection<ActivityData> activityDataCollection;
    @JoinColumn(name = "ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Component component;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activity")
    private Collection<ProcessStructure> processStructureCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activity1")
    private Collection<ProcessStructure> processStructureCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activity2")
    private Collection<ProcessStructure> processStructureCollection2;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idActivity")
    private Collection<FileUsage> fileUsageCollection;

    public Activity() {
    }

    public Activity(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEnergyProfile() {
        return energyProfile;
    }

    public void setEnergyProfile(String energyProfile) {
        this.energyProfile = energyProfile;
    }

    public BigDecimal getExecutionTime() {
        return executionTime;
    }

    public void setExecutionTime(BigDecimal executionTime) {
        this.executionTime = executionTime;
    }

    public BigDecimal getMinExecTime() {
        return minExecTime;
    }

    public void setMinExecTime(BigDecimal minExecTime) {
        this.minExecTime = minExecTime;
    }

    public BigDecimal getMaxExecTime() {
        return maxExecTime;
    }

    public void setMaxExecTime(BigDecimal maxExecTime) {
        this.maxExecTime = maxExecTime;
    }

    public BigDecimal getCPUIdleTime() {
        return cPUIdleTime;
    }

    public void setCPUIdleTime(BigDecimal cPUIdleTime) {
        this.cPUIdleTime = cPUIdleTime;
    }

    public BigDecimal getCPUNormalTime() {
        return cPUNormalTime;
    }

    public void setCPUNormalTime(BigDecimal cPUNormalTime) {
        this.cPUNormalTime = cPUNormalTime;
    }

    public BigDecimal getCPUUsage() {
        return cPUUsage;
    }

    public void setCPUUsage(BigDecimal cPUUsage) {
        this.cPUUsage = cPUUsage;
    }

    public BigDecimal getDiskReadTime() {
        return diskReadTime;
    }

    public void setDiskReadTime(BigDecimal diskReadTime) {
        this.diskReadTime = diskReadTime;
    }

    public BigDecimal getDiskWriteTime() {
        return diskWriteTime;
    }

    public void setDiskWriteTime(BigDecimal diskWriteTime) {
        this.diskWriteTime = diskWriteTime;
    }

    public BigDecimal getDiskIdleTime() {
        return diskIdleTime;
    }

    public void setDiskIdleTime(BigDecimal diskIdleTime) {
        this.diskIdleTime = diskIdleTime;
    }

    public BigDecimal getDiskSleepTime() {
        return diskSleepTime;
    }

    public void setDiskSleepTime(BigDecimal diskSleepTime) {
        this.diskSleepTime = diskSleepTime;
    }

    public BigDecimal getDiskStbTime() {
        return diskStbTime;
    }

    public void setDiskStbTime(BigDecimal diskStbTime) {
        this.diskStbTime = diskStbTime;
    }

    public BigDecimal getDiskUsage() {
        return diskUsage;
    }

    public void setDiskUsage(BigDecimal diskUsage) {
        this.diskUsage = diskUsage;
    }

    @XmlTransient
    public Collection<Service> getServiceCollection() {
        return serviceCollection;
    }

    public void setServiceCollection(Collection<Service> serviceCollection) {
        this.serviceCollection = serviceCollection;
    }

    @XmlTransient
    public Collection<ActivityData> getActivityDataCollection() {
        return activityDataCollection;
    }

    public void setActivityDataCollection(Collection<ActivityData> activityDataCollection) {
        this.activityDataCollection = activityDataCollection;
    }

    public Component getComponent() {
        return component;
    }

    public void setComponent(Component component) {
        this.component = component;
    }

    @XmlTransient
    public Collection<ProcessStructure> getProcessStructureCollection() {
        return processStructureCollection;
    }

    public void setProcessStructureCollection(Collection<ProcessStructure> processStructureCollection) {
        this.processStructureCollection = processStructureCollection;
    }

    @XmlTransient
    public Collection<ProcessStructure> getProcessStructureCollection1() {
        return processStructureCollection1;
    }

    public void setProcessStructureCollection1(Collection<ProcessStructure> processStructureCollection1) {
        this.processStructureCollection1 = processStructureCollection1;
    }

    @XmlTransient
    public Collection<ProcessStructure> getProcessStructureCollection2() {
        return processStructureCollection2;
    }

    public void setProcessStructureCollection2(Collection<ProcessStructure> processStructureCollection2) {
        this.processStructureCollection2 = processStructureCollection2;
    }

    @XmlTransient
    public Collection<FileUsage> getFileUsageCollection() {
        return fileUsageCollection;
    }

    public void setFileUsageCollection(Collection<FileUsage> fileUsageCollection) {
        this.fileUsageCollection = fileUsageCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Activity)) {
            return false;
        }
        Activity other = (Activity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.Activity[ id=" + id + " ]";
    }
    
}
